<%@ taglib prefix="page" uri="http://com.qipay/pagelib" %>
<%@ page language="java" import="com.qipay.admin.utils.SiteHelper" contentType="text/html;charset=utf-8" %>

<%@ page import="com.qipay.baas.model.SpChannelRule" %>
<%@ page import="com.qipay.baas.model.ChannelType" %>
<%@ page import="java.util.List" %>
<!doctype html>
<html>
<head>
    <jsp:include page="head.jsp"></jsp:include>
    <title>编辑SP风控渠道信息</title>
</head>
<body class="devpreview hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <% SpChannelRule spChannelRule = (SpChannelRule) request.getAttribute("detail");
            boolean isAdd = String.valueOf(request.getAttribute("isadd")).equals("1");

        %>
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box box-info">
                        <% if (request.getParameter("error") != null) {%>
                        <div class="alert alert-error">
                            此Sp已经包含这种支付渠道，请重新选择。
                        </div>
                        <%}%>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <form class="form-horizontal" action="save" method="POST" id="doc-vld-msg">
                            <input type="hidden" name="id" value="<%= isAdd?"":String.valueOf(spChannelRule.getId())%>">
                            <div class="box-body" id="dvContent">

                                <div class="form-group">
                                    <label for="txtspid" class="col-sm-2 control-label">SPID：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtspid" name="spId" mush="1"
                                               value="<%= isAdd?"":spChannelRule.getSpId()%>" placeholder="spId">
                                    </div>
                                </div>


                                <div class="form-group">
                                    <label for="txtchanneltype" class="col-sm-2 control-label">支付方式：</label>
                                    <div class="col-sm-10">
                                        <select class="form-control" id="txtchanneltype" name="channelType">
                                            <%
                                                List<ChannelType> channelTypes = (List<ChannelType>)request.getAttribute("channelTypes");
                                                for (ChannelType channelType : channelTypes) {
                                            %>
                                            <option value="<%=channelType.getId()%>"
                                                    <% if (spChannelRule != null &&
                                                            spChannelRule.getChannelType().equals(channelType.getId().byteValue())) {%>
                                                    selected="selected"<%}%>>
                                                <%=channelType.getName()%>
                                            </option>
                                            <%}%>
                                        </select>
                                    </div>
                                </div>


                                <div class="form-group">
                                    <label for="txtmaxtotalamount" class="col-sm-2 control-label">单日支付额度：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtmaxtotalamount"
                                               name="maxTotalAmount" mush="1"
                                               value="<%= isAdd?"":spChannelRule.getMaxTotalAmount()/100%>"
                                               placeholder="单日支付额度">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtcurrenttotalamount" class="col-sm-2 control-label">剩余额度：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtcurrenttotalamount"
                                               name="currentTotalAmount" mush="1"
                                               value="<%= isAdd?"":spChannelRule.getCurrentTotalAmount()/100%>"
                                               placeholder="已支付额度">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txttotalamountlasttime"
                                           class="col-sm-2 control-label">最大支持额度的时间区间：</label>
                                    <div class="col-sm-10">
                                        <input type="date" class="form-control" id="txttotalamountlasttime"
                                               name="totalAmountLastTime"

                                               value="<%= isAdd?"":SiteHelper.getSimpleTimeFormat(spChannelRule.getTotalAmountLastTime())%>"
                                               placeholder="最大支持额度的时间区间">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtmaxorderamount" class="col-sm-2 control-label">最大单笔额度：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtmaxorderamount"
                                               name="maxOrderAmount" mush="1"
                                               value="<%= isAdd?"":spChannelRule.getMaxOrderAmount()/100%>"
                                               placeholder="最大订单额度">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtminorderamount" class="col-sm-2 control-label">最小单笔额度：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtminorderamount"
                                               name="minOrderAmount" mush="1"
                                               value="<%= isAdd?"":spChannelRule.getMinOrderAmount()/100%>"
                                               placeholder="最小订单额度">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtmintimestop" class="col-sm-2 control-label">渠道开启时间：</label>
                                    <div class="col-sm-10">
                                        <input type="time" class="form-control" id="txtmintimestop"
                                               name="minTimeStop" mush="1"
                                               value="<%= isAdd?"":SiteHelper.getTimeFormat(spChannelRule.getMinTimeStop())%>"
                                               placeholder="通道开启时间">
                                    </div>
                                </div>


                                <div class="form-group">
                                    <label for="txtmintimestopduration" class="col-sm-2 control-label">渠道开启时间持续时长（单位hh::mm:ss）</label>
                                    <div class="col-sm-10">
                                        <input type="time" class="form-control" id="txtmintimestopduration"
                                               name="minTimeStopDuration" mush="1"
                                               value="<%= isAdd?"":SiteHelper.getTimeFormat(spChannelRule.getMinTimeStopDuration())%>"
                                               placeholder="通道开启时间持续时长（单位hh:mm:ss）">
                                    </div>
                                </div>

                                <!-- /.box-body -->
                                <div class="box-footer">
                                    <button type="button" class="btn btn-primary btn-sm borderNone" onclick="window.history.back()">返回
                                    </button>
                                    <button type="button" class="btn btn-success btn-sm borderNone" id="btnSearch">确 定</button>
                                </div>
                            </div>
                                <!-- /.box-footer -->
                        </form>
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <%--<jsp:include page="foot.jsp"></jsp:include>--%>
</div>
<script type="text/javascript"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/fastclick.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>
<script>
    $(function () {


        $("#btnSearch").on("click", function () {
            var isGo = true;
            var r = /^\+?[1-9][0-9]*$/;　　//正整数
            var maxorderamount = $("#txtmaxorderamount").val();
            var minorderamount = $("#txtminorderamount").val();
            var maxtotalamount = $("#txtmaxtotalamount").val();
            var currenttotalamount = $("#txtcurrenttotalamount").val();
            isGo = (r.test(minorderamount))&&(r.test(maxorderamount))&&(r.test(maxtotalamount))&&(r.test(currenttotalamount))
            if ( isGo == false) {
                isGo == false
                alert("金额为大于1元的整数")
            }
            isGo=(parseInt(maxorderamount)  >= parseInt(minorderamount))
            if (isGo == false) {
                isGo == false
                alert("最大金额不小于最小金额")
            }

            if (isGo== checkInputMust("dvContent")) {

                $("#doc-vld-msg")[0].submit();
            }
        });
    })


</script>
</body>
</html>

